<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改顶部选项卡')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-title-edit" th:object="${sysTopTitle}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required ">标题：</label>
            <div class="col-sm-8">
                <input name="title" th:field="*{title}" class="form-control" type="text" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required ">标记：</label>
            <div class="col-sm-8">
                <p style="color: red">与后台逻辑绑定，勿轻易修改</p>
                <input name="flag" th:field="*{flag}" class="form-control" type="text" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required ">窗口标题：</label>
            <div class="col-sm-8">
                <input name="targetTitle" th:field="*{targetTitle}" class="form-control" type="text" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required ">链接：</label>
            <div class="col-sm-8">
                <input name="url" th:field="*{url}" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required ">背景色：</label>
            <div class="col-sm-8">
                <input name="colour" th:value="*{colour}" class="" type="hidden" required>
                <div id="chooseBtn"></div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                    <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}" required>
                    <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required ">排序值：</label>
            <div class="col-sm-8">
                <input name="sort" th:field="*{sort}" class="form-control" maxlength="9" type="text" required>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />

<script type="text/javascript">
    var prefix = ctx + "system/title";
    $("#form-title-edit").validate({
        focusCleanup: true
    });

    var parVal = $('input[name=colour]').val();
    layui.use('colorpicker', function(){
        var $ = layui.$
            ,colorpicker = layui.colorpicker;
        //预定义颜色项
        colorpicker.render({
            elem: '#chooseBtn'
            ,color: parVal
            ,predefine: true // 开启预定义颜色
            ,done: function(color){
                $("input[name=colour]").val(color);
            }
        });
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-title-edit').serialize());
        }
    }
</script>
</body>
</html>